Skip to content

Conversation

oliveror
Copy link
Member

Changes

  • Jump to recipe on the detail page only scrolled; keyboard focus stayed on the button, so screen-reader users got no feedback and the next Tab went back into the page header area.
  • It now moves focus to the Ingredients heading (tabIndex={-1}) after scrolling, so the destination is announced and Tab continues inside the recipe.
  • Scrolling is instant instead of smooth when the user has prefers-reduced-motion: reduce.

Validation

  • npm run check passes (214 unit tests), incl. a new test: with reduced motion preferred, scrollIntoView is called with behavior: 'auto' and focus is on the Ingredients heading.

AI usage

Written with Claude Code (Anthropic) to address a teammate's review of the final-delivery findings. Please review the diff as you would any other contribution.

Closes #106

The button only scrolled: keyboard focus stayed on it, and smooth
scrolling ignored prefers-reduced-motion. It now focuses the Ingredients
heading after scrolling (so screen readers announce the destination and
Tab continues there) and scrolls instantly when reduced motion is
preferred.

Closes #106
@oliveror oliveror requested a review from a team as a code owner November 16, 2026 18:12
Copy link
Member

@olestan olestan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes:

  • RecipeDetailPage.tsx:184–186: Moving focus to the Ingredients heading improves screen-reader feedback, but the Ingredients and Instructions sections contain no tabbable elements. Pressing Tab therefore moves focus out of the recipe instead of continuing through its content, leaving the keyboard-navigation issue unresolved.
  • Suggested fix: Ensure keyboard users have an intentional way to continue navigating the recipe, and add a regression test that checks Tab behavior after using "Jump to Recipe", not just the initial focus.

Focusing the Ingredients heading announced the right place, but the
ingredient and step lists have nothing tabbable, so the next Tab left the
recipe. Jump to recipe now lands on the visible "Adjust Servings" heading,
directly above the ingredients; Tab continues to the servings buttons that
scale them. The control exists once per layout and CSS hides the other, so
the rendered copy is picked (falling back to the Ingredients heading).
scroll-margin-top keeps it clear of the sticky header.

Playwright, desktop and mobile: Enter on Jump focuses the heading in view
below the header, then Tab reaches Decrease and Increase servings.
@oliveror
Copy link
Member Author

Thanks, you're right: focus was announced but the next Tab left the recipe. Fixed in the latest commit:

  • Intentional keyboard path: "Jump to recipe" now lands on the Adjust Servings heading. That section sits directly above the ingredients at both breakpoints and is the one control that acts on them. The next Tab goes to Decrease servings, then Increase servings, which rescale the ingredient amounts just below. The ingredient and step lists are static text, so screen-reader users read them with the virtual cursor rather than tabbing; I didn't make headings or list items tabbable. Screen readers now announce "Adjust Servings" when the jump lands.
  • Two copies of the control: it's rendered once per layout, and CSS hides the other copy. Focusing a display:none element silently does nothing, so the handler picks the copy that's actually rendered (getClientRects().length > 0). If neither is rendered, it falls back to the Ingredients heading.
  • Sticky header: the servings section has scroll-margin-top, so the focused heading isn't hidden behind the header.

Tests:

  • New Playwright test, desktop 1280×800 and mobile 390×844, with a long recipe so the jump has to scroll. Enter on "Jump to recipe" focuses the visible heading, which is in the viewport and below the header. Tab focuses Decrease servings, then Increase servings. Both viewports fail on the previous commit.
  • Unit tests cover the rendered-copy choice plus Tab, and the fallback path.

npm run check (215 unit tests) and the full smoke suite (13 tests) pass.

Heads-up: #112 (skip link), #113 (route focus/scroll) and this PR all touch focus and scroll handling, so whichever merges last may need a small rebase.

# Conflicts:
#	apps/web/src/features/recipe-detail/RecipeDetailPage.test.tsx
@oliveror oliveror merged commit bd69fcb into dev Nov 17, 2026
2 checks passed
@oliveror oliveror deleted the fix/a11y-jump-to-recipe branch November 20, 2026 15:31
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants